return {
  "neovim/nvim-lspconfig",
  config = function()
    -- + nvim-lspconfig (lspconfig配置文件插件) --

    --vim.lsp.set_log_level("debug")
    -- Mappings.
    -- See `:help vim.diagnostic.*` for documentation on any of the below functions
    local opts = { noremap=true, silent=true }
    vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
    vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
    vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
    vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)

    -- Use an on_attach function to only map the following keys
    -- after the language server attaches to the current buffer
    local on_attach = function(client, bufnr)
      -- Enable completion triggered by <c-x><c-o>
      --vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')  提示:Deprecated
      vim.bo[bufnr].omnifunc = 'v:lua.vim.lsp.omnifunc'
      -- Mappings.
      -- See `:help vim.lsp.*` for documentation on any of the below functions
      local bufopts = { noremap=true, silent=true, buffer=bufnr }
      vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
      vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
      vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
      vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
      vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
      vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
      vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
      vim.keymap.set('n', '<space>wl', function()
        print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
      end, bufopts)
      vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
      vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
      vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
      vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
      vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
    end

    -- LSP服务设置 --
    local lsp_flags = {
      -- This is the default in Nvim 0.7+
      debounce_text_changes = 150,
    }

    --Enable (broadcasting) snippet capability for completion
    -- capabilities:能力
    local capabilities = vim.lsp.protocol.make_client_capabilities()
    capabilities.textDocument.completion.completionItem.snippetSupport = true

    -- bashls -- bash-language-server
    require('lspconfig')['bashls'].setup {
      filetypes = { "sh", "zsh" },
      on_attach = on_attach,
      flags = lsp_flags,
      capabilities = capabilities,
      settings = {
        bashIde = {
          globPattern = "*@(.sh|.inc|.bash|.command)"
        }
      },
      single_file_support = true,
    }

    -- c/c++ -- pacman安装clang zypper安装clang
    require('lspconfig')['clangd'].setup {
      capabilities = capabilities,
      -- 自定义clangd的参数
      cmd = {
        "clangd",
        "--background - index",
        "--suggest - missing - includes",
        "--clang - tidy",
        "--header - insertion - iwyu",
        "--fallback - style=Google"
      },
      on_attach = on_attach,
      --flags = lsp_flags,
    }

    -- python3 -- sudo npm -g intall pyright ==> 已改为mason安装pyright
    require('lspconfig')['pyright'].setup {
      on_attach = on_attach,
      flags = lsp_flags,
      capabilities = capabilities,
      settings = {
        python = {
          analysis = {
            autoSearchPaths = true,
            diagnosticMode = "workspace",
            useLibraryCodeForTypes = true,
          }
        }
      }
    }

    -- html css js/ts 前端三件套
    -- sudo npm -g install vscode-langservers-extracted => 已改为mason分别安装html,cssls
    require'lspconfig'.html.setup {
      on_attach = on_attach,
      flags = lsp_flags,
      capabilities = capabilities,
    }
    require'lspconfig'.cssls.setup {
      on_attach = on_attach,
      flags = lsp_flags,
      capabilities = capabilities,
    }
    -- typescript(javascript/typescript)
    -- mason安装typescript-language-server
    -- 支持 { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }
    require('lspconfig')['ts_ls'].setup {
      filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
      on_attach = on_attach,
      flags = lsp_flags,
      capabilities = capabilities,
    }

    -- vue3框架lsp
    -- 注意事项：vue3项目中需要(在项目中npm安装就好)npm install typescript,不然打开vue文件时会报错。
    --           tree-sitter的tree-sitter-vue需要安装g++(zypper包管理器的包名为gcc-c++)
    require'lspconfig'.volar.setup{
      -- filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'},
      -- 'javascriptreact', 'typescriptreact' 和已安装的tsserver服务支持的文件类型的有重叠冲突，打开React项目文件时会报错。
      filetypes = {'vue', 'json'},
      on_attach = on_attach,
      flags = lsp_flags,
      capabilities = capabilities,
    }

    -- lua -- mason安装lua-language-server
    require'lspconfig'.lua_ls.setup {
      on_attach = on_attach,
      flags = lsp_flags,
      capabilities = capabilities,
      on_init = function(client)
        --local path = client.workspace_folders[1].name
        local path = vim.fn.stdpath('config') -- 获取 ~/.config/nvim
        ---@diagnostic disable-next-line: undefined-field --临时忽略诊断错误,暂时懒得折腾了,得闲再说...
        if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then
          client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
            Lua = {
              runtime = {
                -- Tell the language server which version of Lua you're using
                -- (most likely LuaJIT in the case of Neovim)
                version = 'LuaJIT',
                -- 设置 Lua 路径，包含 Neovim 的运行时文件
                path = vim.split(package.path, ';'),
              },
              diagnostics = {
                -- 识别 `vim` 作为全局变量
                globals = { 'vim' },
              },
              -- Make the server aware of Neovim runtime files
              workspace = {
                --library = {
                --  vim.env.VIMRUNTIME
                --  -- "${3rd}/luv/library"
                --  -- "${3rd}/busted/library",
                --}
                --vim.fn.stdpath('config'), -- ~/.config/nvim
                --vim.fn.stdpath('data') .. '/site', -- 插件安装目录
                --vim.fn.stdpath('data') .. '/site/pack/*/start/*', -- 插件路径

                ---- or pull in all of 'runtimepath'. NOTE: this is a lot slower
                library = vim.api.nvim_get_runtime_file("", true),
                checkThirdParty = false,
              },
              telemetry = {
                enable = false, -- 禁用遥测
              },
            }
          })
          client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
        end
        return true
      end
  }

  -- java : jdtls : mason安装jdtls,事件比较久,要有点耐心...
  require'lspconfig'.jdtls.setup{
    on_attach = on_attach,
    flags = lsp_flags,
    capabilities = capabilities,
  }

  -- rust: rust_analyzer: mason安装rust-analyzer
  require'lspconfig'.rust_analyzer.setup{
    --on_attach = on_attach,
    --flags = lsp_flags,
    capabilities = capabilities,
    --settings = {
    --  ['rust-analyzer'] = {
    --    diagnostics = {
    --      enable = true;
    --    }
    --  }
    --}
  }

  -- go补全，切换go国内源，在.zshrc配置文件内设置国内源。
  require'lspconfig'.gopls.setup{
    settings = {
      gopls = {
        analyses = {
          unusedparams = true,
          shadow = true,
        },
        staticcheck = true,
      },
    },
  }

  end,
}



